import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import path from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
    AutoImport({
    resolvers: [ElementPlusResolver()],
    dts: 'src/auto-imports.d.ts',
  }),
  Components({
    resolvers: [ElementPlusResolver()],
    dts: 'src/components.d.ts',
  }),
  ],
  resolve: {
    alias: {
       '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
   server: {
    port: 8000, // ✅ 设置你想要的端口号
    host: '0.0.0.0', // 可选：允许局域网访问
    open: true,      // 可选：自动打开浏览器
  }
})
